home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 8.0 KB | 234 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWResFil.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #if !defined(FWRESFIL_H) && !defined(__ODFRC__)
- #define FWRESFIL_H
-
- #ifndef FWPRVRFL_H
- #include "FWPrvRFl.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // CLASS FW_CResourceFile
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CResourceFile FW_AUTO_DESTRUCT_OBJECT
- {
- public:
-
- ~ FW_CResourceFile();
- // Decrements the reference count
- // Delete the resources file rep if count goes to zero.
-
- FW_CResourceFile(const FW_CFileSpecification& newFileSpec);
- // Open a resources file by name.
- // This instance assumes responsibility for closing the file.
-
- FW_CResourceFile(FW_ResourceFileID resFileID);
- // Attach to an already opened resource file.
- // This instance does not assume responsibility for closing the file.
-
- FW_CResourceFile(const FW_CResourceFile& other);
- // Copy constructor, attach to same file as other.
-
- FW_CResourceFile& operator=(const FW_CResourceFile& other);
- // Assignment operator.
-
- const FW_CFileSpecification* GetFileSpecification() const;
- // Get the file specificaiton for the resourcesFile.
-
- FW_Boolean HasResource(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const;
- // Returns TRUE if the resource exists in the file, FALSE if it doesn't.
-
- static FW_ResourceFileID GetSysResourceFileID();
- // Return the FileID for the "system" resources.
- // Can be used to construct a FW_CResourceFile for loading system resources.
-
- // [HLX] Doesn't make much sens in an OpenDoc World
- // static FW_ResourceFileID GetAppResourceFileID();
- // // Return the FileID for the "application" resources.
- // // Can be used to construct a FW_CResourceFile for loading application resources.
-
- FW_ResourceHandle GetResourceHandle(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const;
- // Low level method. Clients should generally use FW_CResource objects.
- // Gets the resource handle. Resource data may still be purgeable or unloaded.
- // Client assumes responsibility to call ReleaseResourceHandle when done.
-
- void ReleaseResourceHandle(FW_ResourceHandle handle) const;
- // Low level method. Clients should generally use FW_CResource objects.
- // Releases the resource handle. All memory is released.
-
- protected:
- FW_CResourceFile();
- // For sub-class
- // This instance does not assume responsibility for closing the file.
-
- void SetRep(const FW_PPrivResourceFile& privResourceFile);
- // For sub-class
-
- private:
-
- #ifdef FW_BUILD_MAC
- // [HLX] Doesn't make much sens in an OpenDoc World
- // static const FW_ResourceFileID gMacAppResFileID;
- #endif
-
- FW_PPrivResourceFile fRep;
-
- public:
-
- // ----- Internal methods
-
- FW_CResourceFile(FW_CPrivResourceFileRep *rep);
- // Attach to the given resources file rep.
-
- FW_Boolean PrivHasSpecialResource(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const;
- // Returns TRUE if the resource exists in the file, FALSE if it doesn't.
-
- FW_PlatformHandle PrivGetSpecialResource(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const;
- // Gets the special resource handle.
- // It is the clients reponsibility to release the handle if necessary,
- // using whatever platform specific code is required.
-
- FW_ResourceFileID PrivGetResourceFileID();
- // Return the platforms's "file ID" for this resources file.
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::SetRep
- //----------------------------------------------------------------------------------------
-
- inline void FW_CResourceFile::SetRep(const FW_PPrivResourceFile& privResourceFile)
- {
- fRep = privResourceFile;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::operator=
- //----------------------------------------------------------------------------------------
-
- inline FW_CResourceFile& FW_CResourceFile::operator=(const FW_CResourceFile& other)
- {
- fRep = other.fRep;
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::GetFileSpecification
- //----------------------------------------------------------------------------------------
-
- inline const FW_CFileSpecification* FW_CResourceFile::GetFileSpecification() const
- {
- return(fRep->GetFileSpecification());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::HasResource
- //----------------------------------------------------------------------------------------
-
- inline FW_Boolean FW_CResourceFile::HasResource(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const
- {
- return fRep->HasResource(resourceId, resourceType);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::GetSysResourceFileID
- //----------------------------------------------------------------------------------------
-
- inline FW_ResourceFileID FW_CResourceFile::GetSysResourceFileID()
- {
- return 0; // System res file ID is 0 on both mac and windows
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::GetResourceHandle
- //----------------------------------------------------------------------------------------
-
- inline FW_ResourceHandle FW_CResourceFile::GetResourceHandle(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const
- {
- return fRep->GetResourceHandle(resourceId, resourceType);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::ReleaseResourceHandle
- //----------------------------------------------------------------------------------------
-
- inline void FW_CResourceFile::ReleaseResourceHandle(FW_ResourceHandle handle) const
- {
- fRep->ReleaseResourceHandle(handle);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::PrivHasSpecialResource
- //----------------------------------------------------------------------------------------
-
- inline FW_Boolean FW_CResourceFile::PrivHasSpecialResource(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const
- {
- return fRep->PrivHasSpecialResource(resourceId, resourceType);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::PrivGetSpecialResource
- //----------------------------------------------------------------------------------------
-
- inline FW_PlatformHandle FW_CResourceFile::PrivGetSpecialResource(FW_ResourceId resourceId,
- FW_ResourceType resourceType) const
- {
- return fRep->PrivGetSpecialResource(resourceId, resourceType);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CResourceFile::PrivGetResourceFileID
- //----------------------------------------------------------------------------------------
-
- inline FW_ResourceFileID FW_CResourceFile::PrivGetResourceFileID()
- {
- return fRep->PrivGetResourceFileID();
- }
-
-
- #if defined FW_BUILD_MAC
- //========================================================================================
- // CLASS FW_CMacResLoadFalse
- //========================================================================================
- // This utility class provides a mechanism to ::SetResLoad(false) and then be
- // assured that ::SetResLoad(true) is executed even in the presend of an FW_THROW
-
- class FW_CLASS_ATTR FW_CMacResLoadFalse FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_CMacResLoadFalse();
- // Sets ResLoad false
-
- virtual ~FW_CMacResLoadFalse();
- // Sets ResLoad true
- };
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-